<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加</title>
</head>
<link rel="stylesheet" href="/static/layui/css/layui.css" />
<body>
<form class="layui-form" id="user-add"  action="" lay-filter="add">
    <input type="hidden" name="hid">
    <div class="layui-form-item">
        <label class="layui-form-label">医院编号：</label>
        <div class="layui-input-inline">
            <input type="text" name="hidnum" lay-verify="required" lay-reqtext="医院编号不能为空！！" autocomplete="off" placeholder="医院名称的首字母组合" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">医院名称：</label>
        <div class="layui-input-inline">
            <input type="text" name="hname" lay-verify="titel" autocomplete="off" placeholder="请输入医院名称" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态：</label>
        <div class="layui-input-block">
            <input type="radio" name="hstatus" value="0" title="正常">
            <input type="radio" name="hstatus" value="1" title="废弃" checked>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>

<script src="/static/js/jquery-3.3.1.js"></script>
<script src="/static/layui/layui.js"></script>
<script>
    //Demo
    layui.use(['form', 'laydate'], function () {
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function (data) {
            var data1 = form.val("add");
            $.ajax({
                url: '/hospital/add',
                type: "post",
                dataType: "json",
                data: data1,
                success: function (da) {
                    if (da.code == 200) {
                        layer.alert("添加成功！", function () {
                            // window.parent.location.reload();//刷新父页面
                            // parent.layer.close(layer.index);//关闭弹出层
                            parent.layer.closeAll();
                        });
                    } else {
                        layer.msg("添加失败！");
                    }
                }
            });
            return false;
        });
    });
</script>
</html>